<div class="breadcrumb">
    <ul id="breadcrumb">
        <li><a href="<?php echo Configure::read('base_url');?>backstage" title="Home">
		<?php echo $this->Html->image("home.png", array("alt" => "Home",'class'=>'home','border'=>'0'));?>
		</a></li>
        <li><a href="<?php echo Configure::read('base_url');?>backstage/products/ptrack_disapproved" title="product tracking">Dispute</a></li>
    </ul>
</div>
<?php echo $this->element('admin/admin_leftmenu'); ?>
<div id="left">   
    <?php
    echo $this->Session->flash();
    if ($this->Session->check('Message.auth'))
        echo $this->Session->flash('auth');
    ?>
    <div class="div_header"><?php __('Dispute'); ?></div>
    <div class="div_content">
       
        <div >
            <div  style="width:690px; background:  #ccc; margin-top: 5px; padding: 5px;color: black;">Search</div>
             <div >
           <form method="post" id="searchfrm" action="<?php echo Configure::read('base_url')."backstage/products/ptrack_disapproved"; ?>">
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td  style="border:0px;text-align: right;">Search By:</td><td   style="border:0px; width: 50px; text-align: left;">
        <input type="text" size="36"  id="serchkey" name="serchkey" class="anyOnerequired" title="Please enter keyword." value="Enter Product Item #, Title or Seller ID" onfocus="if(this.value=='Enter Product Item #, Title or Seller ID'){this.value=''}" onblur="if(this.value==''){this.value='Enter Product Item #, Title or Seller ID'}"/>
</td><td  style="border:0px;"><select name="data[type]">
    <option value="item">Item #</option>
    <option value="title">Title</option>
    <option value="sellerid">Seller ID</option>
</select><input type="submit" style="background:#73AE0B;
color:#fff; font-size:14px;" name="button" id="button" value="Search" />
</td>
</tr>
</table>
</form>
  <div id='message_success'></div>
         </div>
            </div>
           <table id="category_table" cellspacing="0" class="tablesorter">
          <tr>
            <th bgcolor="#ccc">Case ID</th>
            <th bgcolor="#ccc">Opened On</th>
            <th bgcolor="#ccc">Expires On</th>
            <th bgcolor="#ccc">Seller ID</th>
            <th bgcolor="#ccc">Status</th>
            <th bgcolor="#ccc">Action</th>
        </tr>
	<?php if(!empty($disputelist)): ?>
	<?php foreach($disputelist as $dispute):?>
        <tr id="row_<?php echo $dispute['Dispute']['id'];?>">
                <td style="vertical-align: middle;">
                     <a href="javascript:void(0);" controller="products" action="viewdispute"
                       ElmID="<?php echo $dispute['Dispute']['id']; ?>" onclick='showPop(this)'> <?php echo $dispute['Dispute']['id'];?></a>
                </td>
                <td style="vertical-align: middle;">
                 <?php echo date('d-m-Y',  strtotime($dispute['Dispute']['open_date']));?>
                </td>
                <td style="vertical-align: middle;">
                    <?php echo date('d-m-Y',  strtotime($dispute['Dispute']['expire_date']));?>
                </td>
                <td style="vertical-align: middle;">
                <?php echo $dispute['Seller']['username'];?>
                </td>
                <td style="vertical-align: middle;">
                <?php echo $dispute['Dispute']['status'];?>
                </td>
                <td style="vertical-align: middle;">
               <a href="javascript:void(0);" controller="messages" action="dispute_message" title="Respond"
                       ElmID="<?php echo $dispute['Dispute']['id']; ?>"  ElmID2="2" onclick='showPop(this)'>Respond</a>&nbsp;|&nbsp;
               <a href="javascript:void(0);" controller="messages" action="dispute_message" title="History"
                       ElmID="<?php echo $dispute['Dispute']['id']; ?>" ElmID2="1" onclick='showPop(this)'>History</a><br />
                                 
               <a href="javascript:void(0);" controller="products" action="addnote_dispute" title="Add a Note"
                       ElmID="<?php echo $dispute['Dispute']['id']; ?>"  onclick='showPop(this)'>Add a Note</a>&nbsp;|&nbsp;
               <a href="javascript:void(0);"  id="<?php echo $dispute['Dispute']['id']; ?>" class="close_dispute">Close</a>
                </td>
        </tr>
        <?php
        $comments = $this->requestAction('/products/getdisputenote/'.$dispute['Dispute']['id']);
        //pr($comments);
        if(!empty ($comments)){
?>
       <tr    class="fullrow">
            <td colspan="6"  style="background: none repeat scroll 0pt 0pt BlanchedAlmond;text-align: left;"><b>My Note:</b>
    <?php

        foreach($comments as $comment) {
        echo $comment['Disputenote']['note'];echo"<br/>";
        //$j++;

        }
?>
</td></tr>
        <?php

        }
        ?>
            <?php
            endforeach;
            ?>
</table>
<?php else:?>
<br /><br />
<h2>Your Dispute list is empty.</h2>
<br /><br /><br />
<?php endif;?>
<?php  //echo $html->script(array("jquery.min.js")); ?>
<script type="text/javascript">
    jQuery(document).ready(function(){

        jQuery(".close_dispute").click(function(){

            var mid=jQuery(this).attr('id');

            jQuery.ajax({
                type: 'GET',
                url : baseurl+'products/close_dispute/'+mid,
                dataType: 'html',
                success: function(data){
                    window.location.reload();
                }
            });

        });
        ///////////////////////mediation
        jQuery(".Mediation_dispute").click(function(){

            var mid=jQuery(this).attr('id');

            jQuery.ajax({
                type: 'GET',
                url : baseurl+'products/mediation_dispute/'+mid,
                dataType: 'html',
                success: function(data){
                    window.location.reload();
                }
            });

        });

    });
</script>
                </div>
            <div class="div_bottom"></div>
        </div>

        <!-- edit sidebar items here -->

    </div>